

import 'package:flutter/material.dart';

import '../../utils/sp_utils.dart';

class PersonInfoViewModel with ChangeNotifier {
  String _userName = '';
  String _phone = '';
  String _avatarUrl = '';

  String get userName => _userName;
  String get phone => _phone;
  String get avatarUrl => _avatarUrl;

  void setUserName(String newUserName) {
    _userName = newUserName;
    notifyListeners();
  }

  void setAvatarUrl(String newAvatarUrl) {
    _avatarUrl = newAvatarUrl;
    notifyListeners();
  }

  Future<void> showUserInfo() async {
    final user = await SpUtils.getUserData();
    _userName = user!.userName;
    _phone = user.mobile;
    _avatarUrl = user.avatar;
    notifyListeners();
  }
}